class Attrezzo < ActiveRecord::Base
  acts_as_paranoid unless SHOW_DELETED
  belongs_to :tipo_attrezzo
  belongs_to :centro_costo
  belongs_to :fornitore, :class_name => 'Partner'#, :foreign_key => 'fornitore_id' 
  #has_many :manutenzioni_attrezzo, :dependent => :protect, :class_name => 'ManutenzioneAttrezzo'
  has_many :note, :as => :nota_ref, :dependent => :protect
  has_many :allegati, :as => :allegato_ref, :dependent => :destroy
  
  validates_presence_of :numero, :modello, :tipo_attrezzo
  validates_uniqueness_of :numero, :scope => :deleted_at, :case_sensitive => false

  def name
	  "#{numero} :: #{marca} - #{modello}"
  end
end
